//链接删除和锁定
$(function(){
   $('a#link-delete').click(function(){
      var obj = $(this);
      var id = obj.parent().find('input[name=link-id]').val();
      $.ajax({
         url:'/admin/link/delete',
         type:'post',
         data:{id:id},
         dataType:'json',
         success:function(data){
             if(data.code != undefined && data.code == 1){
                 if(data.status != undefined && data.status == 1){
                     obj.removeClass('btn-primary');
                 }
                 
             }
             
             if(data.code != undefined && data.code == 1){
                 if(data.status != undefined && data.status == 0){
                     obj.addClass('btn-primary');
                 }
             }
         }
      });
      return false;
   });
   
   $('a#link-lock').click(function(){
        var obj = $(this);
        var id = obj.parent().find('input[name=link-id]').val();
        $.ajax({
           url:'/admin/link/lock',
           type:'post',
           data:{id:id},
           dataType:'json',
           success:function(data){
                if(data.code != undefined && data.code == 1){
                    if(data.lock != undefined && data.lock == 1){
                        obj.removeClass('btn-primary');
                    }
                }

                if(data.code != undefined && data.code == 1){
                    if(data.lock != undefined && data.lock == 0){
                        obj.addClass('btn-primary');
                    }
                }
           }
        });
        return false;
   });
});